home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
qlib205.zip
/
QLIB.ZIP
/
SRC
/
QLIB
/
MEM.ASM
< prev
next >
Wrap
Assembly Source File
|
1997-01-09
|
2KB
|
153 lines
include qlib.inc ;setup
include dos.inc
include string.inc
.code
;this can handle overlaps! (but the src is destoyed of course)
memcpy proc uses edi esi ecx,dest:dword,src:dword,len:dword
pushad
.if !len
popad
mov eax,dest
ret
.endif
mov esi,src
mov edi,dest
mov ecx,len
.if esi<edi
;copy backwards
std
add esi,ecx
add edi,ecx
dec esi ; FIX : Ver 1.1
dec edi ; "
.endif
rep movsb
cld
popad
mov eax,dest
ret
memcpy endp
memcmp proc uses esi edi ecx,p1:dword,p2:dword,len:dword
pushad
mov esi,p1
mov edi,p2
mov ecx,len
@@:
repz cmpsb
ja above
jb below
popad
xor eax,eax
ret
above:
popad
mov eax,1
ret
below:
popad
mov eax,-1
ret
memcmp endp
memset proc uses ecx edi,p:dword,val:byte,len:dword
mov ecx,len
mov edi,p
mov al,val
rep stosb
mov eax,p
ret
memset endp
;same as memset except args order
setmem proc uses ecx edi,p:dword,len:dword,val:byte
mov ecx,len
mov edi,p
mov al,val
rep stosb
mov eax,p
ret
setmem endp
memchr proc uses ecx edi,s1:dword,c1:byte,len:dword
mov ecx,len
mov edi,s1
mov al,c1
repnz scasb
ja above
jb below
xor eax,eax
ret
above:
mov eax,1
ret
below:
mov eax,-1
ret
memchr endp
memccpy proc,d1:dword,s1:dword,c1:byte,len:dword
pushad
callp strlen,s1
mov edi,s1
mov ecx,eax
mov ebx,eax
mov al,c1
repnz scasb
.if !zero?
mov ecx,len
mov dptr[esp+7*4],0 ;return NULL
jmp @f
.endif
sub ebx,ecx
mov ecx,ebx
mov eax,d1
add eax,ecx
mov [esp+7*4],eax
@@:
mov esi,s1
mov edi,d1
rep movsb
popad
ret
memccpy endp
memicmp proc uses esi edi ecx,p1:dword,p2:dword,len:dword
pushad
mov esi,p1
mov edi,p2
mov ecx,len
@@:
lodsb
.if (al>='a') && (al<='z')
add al,'A'-'a'
.endif
mov bl,al
mov al,[edi]
inc edi
.if (al>='a') && (al<='z')
add al,'A'-'a'
.endif
cmp bl,al
ja above
jb below
dec ecx
jnz @b
popad
xor eax,eax
ret
above:
popad
mov eax,1
ret
below:
popad
mov eax,-1
ret
memicmp endp
end